<?php
// +----------------------------------------------------------------------
// | Created by PHPstorm: [ JRK丶Admin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: Lucky
// +----------------------------------------------------------------------
// | Date: 2020-08-14 16:27:12
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------

namespace app\admin\controller;
use app\admin\model\ArticleModels;
use app\common\controller\AdminBaseController;
use Jrk\Tree;
use think\Exception;
use think\facade\Db;
use think\facade\Route;
use think\Request;
use app\admin\model\ArticleCates;
use app\admin\service\ExcelService;

class ArticleCate extends AdminBaseController
{

    protected function initialize()
   {
           parent::initialize(); // TODO: Change the autogenerated stub

           $this->model = new ArticleCates();

           $this->assign("models",ArticleModels::adminGetModelSelect());

           $this->assign("tree",Tree::toFormatTree($this->model->select()->toArray(), "name"));
    }



   /**
     * @param Request $request
     * @return string|\think\response\Json
     * @author: 
     * @describe:添加
     */
    public function add(Request $request){
        $info=[];
        $this->assign(compact("info"));
        return $this->fetch();
    }


    /**
     * @param $id
     * @return string|\think\response\Json
     * @author: 
     * @describe:编辑
     */
    public function edit($id){
        $info=$this->model->where("id",$id)->find()->toArray();
        if (!$info){
            return parent::failed("未查询到数据");
        }
        $this->assign(compact("info"));
        return $this->fetch("add");
    }


}